<template>
  <header class='app-header'>
    <div class="container">
      <h1 class="logo">
        <RouterLink to="/">小兔鲜</RouterLink>
      </h1>
      <AppHeaderNav />
      <div class="search">
        <i class="iconfont icon-search"></i>
        <input type="text" placeholder="搜一搜">
      </div>
      <div class="cart">
        <a class="curr" href="#">
          <i class="iconfont icon-cart" @click="add" id="a"></i><em>2</em>
          <div class="box" id="b">
            <img src="../assets/img/CartLogo.png" alt="">
          </div>
        </a>
      </div>
    </div>
  </header>
</template>
  

<script>
import AppHeaderNav from '@/components/AppHeader-nav.vue'
export default {
  components: { AppHeaderNav },
  methods:{
    add() {
      // alert(123)
      let a = document.getElementById("a");
      let b = document.getElementById("b");
      // console.dir(a)
      console.dir(b)
      a.onmouseover = function() {
        // alert(123)
        b.style.opacity = 1;
      }
      a.onmouseout = function() {
        // alert(123)
        b.style.opacity = 0;
      }
      setTimeout(()=>{
        this.$router.push('/cart')
      },5000)
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../assets/css/color.scss";

@mixin set($color) {
  //   font-size: $size;
  color: $color;
}

.app-header {
  background: rgb(255, 255, 255);
  box-shadow: 0 0 10px black;

  .container {
    display: flex;
    align-items: center;
  }

  .logo {
    width: 200px;

    a {
      display: block;
      height: 132px;
      width: 100%;
      text-indent: -9999px;
      background: url(../assets/download.png) no-repeat center 18px / contain;
    }
  }

  .navs {
    width: 820px;
    display: flex;
    justify-content: space-around;
    padding-left: 40px;

    li {
      margin-right: 40px;
      width: 38px;
      text-align: center;

      a {
        font-size: 16px;
        line-height: 32px;
        height: 32px;
        display: inline-block;
      }

      &:hover {
        a {
          @include set($xtxColor);
          border-bottom: 1px solid #27ba9b;
        }
      }
    }
  }

  .search {
    width: 170px;
    height: 32px;
    position: relative;
    border-bottom: 1px solid #e7e7e7;
    line-height: 32px;

    .icon-search {
      font-size: 18px;
      margin-left: 5px;
    }

    input {
      width: 140px;
      padding-left: 5px;
      color: #666;
    }
  }

  .cart {
    width: 50px;

    .curr {
      height: 32px;
      line-height: 32px;
      text-align: center;
      position: relative;
      display: block;
      position: relative;
      
      .icon-cart {
        font-size: 32px;
      }
      
      .box {
        width: 400px;
        height: 400px;
        position: absolute;
        top: 50px;
        right: 0;
        z-index: 99999;
        box-shadow: 0 0 10px black;
        opacity: 0;
        // display: none;
        img {
          width: 100%;
          height: 100%;
        }
      }

      em {
        font-style: normal;
        position: absolute;
        right: 0;
        top: 0;
        padding: 1px 6px;
        line-height: 1;
        background: #e26237;
        color: #fff;
        font-size: 12px;
        border-radius: 10px;
        font-family: Arial;
      }
    }
  }
}
</style>